<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/tag.jsp"%>
<script type="text/javascript">

function d(obj){
	var id= obj.getAttribute("id");//试题的id
	var name= obj.getAttribute("name");//试题的id
	var answer = obj.getAttribute("value");//选择的答案
	
	
	var input= document.getElementsByTagName("input");

	for ( var ic = 0; ic < input.length; ic++) {
			if (input[ic].type == "checkbox" && input[ic].checked)//是否是checkbox且是选中的
			{
				alert(input[ic].name)// 弹出那么值
			}
		}
	}

	function t(obj) {
		var id = obj.getAttribute("name");//试题的id
		var answer = obj.getAttribute("value");//选择的答案
		var truean = obj.getAttribute("id");//正确答案
		var flag;
		var userId = $("#userId").val();
		var testid = $("#testid").val();
		var coun = $("#coun").val();

		if (answer == truean) {
			//选对了
			$.ajax({
				type : "post",
				url : "answer/test/ajaxFlag.do",
				async : false,
				data : {
					"id" : id,
					"flag" : "1",//正确
					"userId" : userId,
					"testid" : testid,
					"coun" : coun,
					"type" : "1",//单选题
				},
				dataType : "json"
			});

		} else {
			//选错了
			$.ajax({
				type : "post",
				url : "answer/test/ajaxFlag.do",
				async : false,
				data : {
					"id" : id,
					"flag" : "0",//正确
					"userId" : userId,
					"testid" : testid,
					"coun" : coun,
					"type" : "1",//单选题
				},
				dataType : "json"
			});
		}
	}
</script>
<SCRIPT LANGUAGE="JavaScript">   

<!--
	var toutaltime = $("#toutaltime").val();
	var maxtime = toutaltime * 60
	//一个小时，按秒计算，自己调整!   
	function CountDown() {
		if (maxtime >= 0) {
			minutes = Math.floor(maxtime / 60);
			seconds = Math.floor(maxtime % 60);
			msg = "距离结束还有" + minutes + "分" + seconds + "秒";
			document.all["timer"].innerHTML = msg;
			if (maxtime == 5 * 60)
				alert('注意，还有5分钟!');
			--maxtime;
		} else {
			clearInterval(timer);
			alert("时间到，结束!");
		}
	}
	timer = setInterval("CountDown()", 1000);
//-->
</SCRIPT>   


<div class="bjui-pageHeader">

   <h3 style="text-align:center; ">考试答题</h3>

</div>

<div class="bjui-pageContent">

    <div class="bjui-headBar">
        <!-- 顶部工具条 -->
        <div id="timer" style="color:red"></div>   
    </div>

    <div data-layout-h="0">
        <!-- 内容区 分成左右两部分，左侧为答题区，右侧为时间提示、提交按钮-->
		<div style="float:left;width:75%;border-right:1px dashed black;text-align:center;margin-left:5%">
			<div style="text-align:left; ">
			<input type="hidden" name="toutaltime" id="toutaltime" value="${toutaltime}">
			<input type="hidden" name="testid" id="testid" value="${testid}">
			<input type="hidden" name="userId" id="userId" value="${userId}">
			<input type="hidden" name="coun" id="coun" value="${coun}">
				<br/>
				一、单选题
				<c:choose>
				<c:when test="${not empty newSlist}">
				<c:forEach items="${newSlist}" var="dx" varStatus="s">
					<input type="hidden" name="id" id="id" value="${dx.id}">
					<input type="hidden" name="answer" id="answer" value="${dx.answer}">
					<h5>${s.index+1}、${dx.title}</h5>
					<p>	
					<input type="radio" name="${dx.id}"  value="a" id="${dx.answer}" onClick="t(this)">A：${dx.optiona}
					</p>
					<p>
					<input type="radio" name="${dx.id}"  value="b" id="${dx.answer}" onClick="t(this)">B：${dx.optionb}
					</p>
					<c:if test="${not empty dx.optionc}">
						<p>
						<input type="radio" name="${dx.id}"  value="c" id="${dx.answer}" onClick="t(this)">C：${dx.optionc}
						</p>
					</c:if>
					<c:if test="${not empty dx.optiond}">
						<p>
						<input type="radio" name="${dx.id}"  value="d" id="${dx.answer}" onClick="t(this)">D：${dx.optiond}
						</p>
					</c:if>
					<c:if test="${not empty dx.optione}">
						<p>
						<input type="radio" name="${dx.id}"  value="e" id="${dx.answer}" onClick="t(this)">E：${dx.optione}
						</p>
					</c:if>
					<c:if test="${not empty dx.optionf}">
						<p>
						<input type="radio" name="${dx.id}"  value="f" id="${dx.answer}" onClick="t(this)">F：${dx.optionf}
						</p>
					</c:if>
					<br/>
				</c:forEach>
				</c:when>
				</c:choose>
					
				二、多选题
				<c:choose>
				<c:when test="${not empty newMlist}">
				<c:forEach items="${newMlist}" var="dx" varStatus="s">
					<input type="text" name="c${dx.id}" id="c${dx.id}" value="">
					<h5>${s.index+1}、${dx.title}</h5>
					<p>
						<input type="checkbox" name="c${dx.id}" id="c${dx.id}" value="a"  onClick="d(this)">A：${dx.optiona}
					</p>
					<p>	
						<input type="checkbox" name="c${dx.id}" id="c${dx.id}" value="b"  onClick="d(this)" >B：${dx.optionb}
					</p>
					<c:if test="${not empty dx.optionc}">
						<p>	
						<input type="checkbox" name="c${dx.id}" id="c${dx.id}" value="c"  onClick="d(this)" >C：${dx.optionc}
						</p>
					</c:if>
					<c:if test="${not empty dx.optiond}">
						<p>	
						<input type="checkbox" name="c${dx.id}" id="c${dx.id}" value="d" onClick="d(this)" > D：${dx.optiond}
						</p>
					</c:if>
					<c:if test="${not empty dx.optione}">
						<p>	
						<input type="checkbox" name="${dx.id}" id="c${dx.id}" value="e" >E：${dx.optione}
						</p>
					</c:if>
					<c:if test="${not empty dx.optionf}">
						<p>	
						<input type="checkbox" name="${dx.id}" id="c${dx.id}" value="f" >F：${dx.optionf}
						</p>
					</c:if>
					
					<a href="" class="btn-blue" >提交</a>
					
					<br/>
				</c:forEach>
				</c:when>
				</c:choose>
				三、判断题
				<c:choose>
				<c:when test="${not empty newPlist}">
				<c:forEach items="${newPlist}" var="dx" varStatus="s">
					<h5>${s.index+1}、${dx.title}</h5>
					<p>
						<input type="radio" name="radio${dx.id}" id="j_form_radio1" value="1" data-toggle="icheck" data-label="A：${dx.optiona}">
					</p>
					<p>	
						<input type="radio" name="radio${dx.id}" id="j_form_radio2" value="0" data-toggle="icheck" data-label="B：${dx.optionb}">
					</p>
				</c:forEach>
				</c:when>
				</c:choose>
			</div>
		</div>
		<div style="float:left;width:25%;margin:0 auto">
			<div style="position: absolute;right:8%;top:50%">
				
				答题时间<br/>
				<input type="button" class="btn-red" value="&nbsp;&nbsp;交&nbsp;&nbsp;卷&nbsp;&nbsp;"/>
			</div>
		</div>
    </div>

    <div class="bjui-footBar">

        <!-- 底部工具条  -->

    </div>

</div>
